#include "CurveTableView.h"

#include <QHeaderView>
#include "CurveTableModel.h"

CurveTableView::CurveTableView(QWidget *parent) : QTableView(parent)
{
    Init();
}

CurveTableView::~CurveTableView()
{
}

void CurveTableView::SetShowPoints(const QList<QSharedPointer<Point>> &showPoints)
{
    curveTableModel->SetShowPoints(showPoints);
}

void CurveTableView::Update()
{
    curveTableModel->Update();
}

void CurveTableView::Init()
{
    verticalHeader()->setHidden(true);
    horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder);
    setSelectionBehavior(QAbstractItemView::SelectRows);
    horizontalHeader()->setHighlightSections(false);
    horizontalHeader()->setStretchLastSection(true);

    setShowGrid(false);
    setAlternatingRowColors(true);

    curveTableModel = new CurveTableModel(this);
    auto headers = QStringList { tr("Index"), tr("Name"), tr("T1"), tr("T2") };
    curveTableModel->SetHeaders(headers);
    setModel(curveTableModel);

    setColumnWidth(0, 45);
    setColumnWidth(1, 95);
    setColumnWidth(2, 80);
    setColumnWidth(3, 80);

    //connect(this, &TestTableView::doubleClicked, this, &TestTableView::SlotTestTableItemDoubleClicked);
}
